package com.songlanyun.modules.share.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.songlanyun.common.drive.RootEntity;
import com.songlanyun.common.enums.OpusConstant;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * 分享记录表
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2021-02-24 17:23:18
 */
@Data
@TableName("yxt_bbs_share_record")
public class ShareRecord extends RootEntity<Long, ShareRecord> implements Serializable {
    private static final long serialVersionUID = 1L;

    public ShareRecord() {
    }

    public ShareRecord(OpusConstant.ModelType modelType, Long modelId, Long shareUserId, Long publisherId, Date time) {
        this.modelType = modelType;
        this.modelId = modelId;
        this.shareUserId = shareUserId;
        this.publisherId = publisherId;
        this.lastTime = time;
    }

    /**
     *
     */
    @TableId
    private Long id;
    /**
     * 分享类型
     * 0：作品
     * 1：文章
     * 2：商品
     * 3：服务
     * 4：其他
     */
    @NotNull(message = "分享类型不能为空")
    private OpusConstant.ModelType modelType;
    /**
     * 关联id
     */
    @NotNull(message = "关联主键不能为空")
    private Long modelId;
    /**
     * 模型是否存在
     */
    private Boolean modelExist;
    /**
     * 转发人
     */
    @NotNull(message = "转发人不能为空")
    private Long shareUserId;
    /**
     * 发布人id
     */
    @NotNull(message = "发布人不能为空")
    private Long publisherId;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 最后一次分享时间
     */
    private Date lastTime;


    @Override
    public Long getIdentity() {
        return this.getId();
    }
}
